const ProjectRequest = require("../project/project_request.js");
const Url = require("../utils/url.js");

function page(startPage, callback){
  const URL = Url.newInstance("/ticket/offset/page");
  URL.setPara('startPage', startPage)
  ProjectRequest.getRequest(URL.get(), callback);
}

function findById(id, callback) {
  const url = "/ticket/offset/" + id;
  ProjectRequest.getRequest(url, callback);
}

function accept(id, callback) {
  const url = "/ticket/offset/accept/" + id;
  ProjectRequest.getRequest(url, callback);
}

/** 
 * 可用电子券列表
 */
function usePage(startPage, callback) {
  const URL = Url.newInstance("/ticket/offset/use/page");
  URL.setPara('startPage', startPage);
  ProjectRequest.getRequest(URL.get(), callback);
}

/** 
 * 获取最近到期可用电子券
 */
function findExpiry(callback) {
  const url = "/ticket/offset/expiry";
  ProjectRequest.getRequest(url, callback);
}

/**
 * exports
 */
module.exports = {
  page, usePage,
  findById,
  findExpiry,
  accept
};